package com.shujia.mr.hanlpdemo;

import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.dictionary.CustomDictionary;
import com.hankcs.hanlp.seg.Segment;
import com.hankcs.hanlp.seg.common.Term;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.List;

// 斗罗大陆 灵力 武魂碎片  蓝银草 武魂殿
public class FenciDemo3 {
    public static void main(String[] args) throws Exception {

        loadDict("hadoop/src/main/java/com/shujia/mr/hanlpdemo/words.txt");

        Segment segment = HanLP.newSegment();

        BufferedReader br = new BufferedReader(new FileReader("hadoop/src/main/java/com/shujia/mr/hanlpdemo/dldl.txt"));

        String line = null;
        while ((line = br.readLine()) != null) {
            List<Term> termList = segment.seg(line);
            termList.forEach(e-> System.out.println(e.word));
            System.out.println("=========================");
        }
    }

    public static void loadDict(String line) throws Exception{
        BufferedReader br = new BufferedReader(new FileReader(line));
        String line2 = null;
        while ((line2 = br.readLine()) != null) {
            CustomDictionary.add(line2);
        }
    }
}
